package net.jueb.juebCore.net.client;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import net.jueb.juebCore.net.message.AppMessage;
import net.jueb.util4j.net.nettyImpl.client.NettyWebSocketClient;

public class GameNettyWebSocketClient extends NettyWebSocketClient implements NetClient{

	public GameNettyWebSocketClient(String host, int port, String url,
			ChannelInitializer<SocketChannel> channelInitializer,
			EventLoopGroup group) throws Exception {
		super(host, port, url, channelInitializer, group);
	}

	public GameNettyWebSocketClient(String host, int port, String url,
			ChannelInitializer<SocketChannel> channelInitializer)
			throws Exception {
		super(host, port, url, channelInitializer);
	}

	@Override
	public void close() {
		super.stop();
	}

	@Override
	public void sendMessage(AppMessage msg) {
		super.sendObject(msg);
		super.flush();
	}

	@Override
	public void sendData(byte[] data, int offset, int count) {
		byte[] data2=new byte[count];
		System.arraycopy(data, 0, data2, offset, count);
		super.sendData(data2);
		super.flush();
	}

	@Override
	public boolean isActive() {
		return super.isConnected();
	}
	@Override
	public void startNetWork() {
		super.start();
	}
}
